<template>
	<view class="columnbox wdh-100 content" v-if="prescriptionxy!=''">
		<view class="t-box wdh-100" v-if="prescriptionxy.addtime">{{getDate(prescriptionxy.addtime)}} 开方
		</view>
		<view class="columnbox info-box">
			<view class="i-title">·辩证·</view>
			<view class="wdh-100 bz-box">
				【患者信息】{{prescriptionxy.name}} {{prescriptionxy.sex=='2'?'女':'男'}} {{prescriptionxy.age}}岁
			</view>
			<view class="wdh-100 bz-box">
				【诊断】{{prescriptionxy.bianbing}}
			</view>
		</view>
		<view class="columnbox info-box" style="position: relative;">
			<view class="i-title">·开方·</view>
			<view class="wdh-100 bz-box" style="font-size: 40rpx;">
				R：
			</view>
			<view class="wdh-100 bz-box columnbox">
				<view v-for="(item,index) in prescriptionxydrug" :key='index' class="wdh-100 columnbox">
					<view class="wdh-100"> {{item.medicine}}  {{item.guige}} 【{{item.num}}】</view>
					<view class="wdh-100" style="margin-top: 10rpx;margin-bottom: 20rpx;color: #7a7c7c;">
						用法：{{item.yongfa}}
						{{item.pinci}} {{item.yongliang}}{{item.ylunit}}/次
					</view>
				</view>
			</view>
			<image src="/static/img/seal.jpg" mode="widthFix" class="seal-img"></image>
		</view>

		<view class="columnbox info-box">
			<view class="i-title">·医嘱事项·</view>
			<view class="wdh-100 bz-box">
				{{prescriptionxy.yizhu||'无'}}
			</view>
		</view>
		<view class="columnbox info-box">
			<view class="wdh-100" style="text-align: right;" v-if="prescriptionxy.addtime">
				{{getDate(prescriptionxy.addtime)}}
			</view>
			<view class="wdh-100 rowbox jus bz-box als">
				【医生签名】 <image style="width: 320rpx;margin-left: 20rpx;" :src="prescriptionxy.qianming" mode="widthFix">
				</image>
			</view>
		</view>
		<view class="t-box wdh-100">注：本处方当日有效</view>
		<template v-if="prescriptionxy.paystatus<2">
			<view style="width: 100%;height: 200rpx;"></view>
			<view class="rowbox wdh-100 bottom-box">
				<view class="rowbox wdh-100 send-btn" @click="updateInfo">修改</view>
			</view>
		</template>
		<template v-else-if="prescriptionxy.paystatus>=2">
			<view style="width: 100%;height: 200rpx;"></view>
			<view class="rowbox wdh-100 bottom-box">
				<view class="rowbox wdh-100 send-btn" @click="reAddOrder">再来一单</view>
			</view>
		</template>
	</view>
</template>

<script>
	import time from '@/utils/time.js'
	export default {
		data() {
			return {
				id: 0,
				prescriptionxy: '',
				prescriptionxydrug: ''
			};
		},
		onLoad(options) {
			this.id = options.id * 1
			this.getDetail()
		},
		methods: {
			reAddOrder() {
				uni.redirectTo({
					url: '/packageA/yaofang/kaifang?id=' + this.prescriptionxy.userid + '&kfid=' + this.id +
						'&type=xiyao&reOrder=true'
				})
			},
			updateInfo() {
				uni.redirectTo({
					url: '/packageA/yaofang/kaifang?id=' + this.prescriptionxy.userid + '&kfid=' + this.id +
						'&type=xiyao'
				})
			},
			getDate(v) {
				return time.toLocalDate(v)
			},
			getDetail() {
				this.$req.post('/doctor/prescriptionxyinfo', {
					id: this.id
				}).then(res => {
					this.prescriptionxy = res.data.data.prescriptionxy
					this.prescriptionxydrug = res.data.data.prescriptionxydrug
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F5F8FB;
		min-height: 100vh;
		justify-content: flex-start;
		font-family: PingFang SC;
		font-size: 28rpx;
	}

	.t-box {
		padding: 20rpx 32rpx;
		box-sizing: border-box;
		color: #626262;
	}

	.info-box {
		background: #fff;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		padding: 32rpx 32rpx;
		width: 710rpx;
	}

	.i-title {
		font-weight: bold;
		// margin-bottom: 10rpx;
	}

	.bz-box {
		margin-top: 20rpx;
	}

	.jixing-box {
		border-bottom: #b2b4b7 dotted 1px;
		padding-bottom: 20rpx;
	}

	.prescriptionxydrug-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		line-height: 50rpx;

		view {
			margin-right: 32rpx;
		}
	}

	.yl-box {
		text {
			color: #f17267;
			margin: 0 10rpx;
		}
	}

	.seal-img {
		width: 240rpx;
		height: 240rpx;
		position: absolute;
		bottom: 40rpx;
		z-index: 2;
		right: 40rpx;
	}
</style>